package com.mdd.front.controller.yangyangLeadingEnterprise.index;

import com.mdd.common.aop.NotLogin;
import com.mdd.common.entity.yangyangLeadingEnterprise.TAppBanner;
import com.mdd.common.entity.yangyangLeadingEnterprise.TAppPolicyNews;
import com.mdd.common.entity.yangyangLeadingEnterprise.TAppStore;
import com.mdd.common.entity.yangyangLeadingEnterprise.common.JsonReturn;
import com.mdd.common.entity.yangyangLeadingEnterprise.dto.AppStoreDTO;
import com.mdd.common.entity.yangyangLeadingEnterprise.param.*;
import com.mdd.front.service.yangyangLeadingEnterprise.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/api/app/index")
@Api(tags = "app首页")
public class AppIndexController {

    @Resource
    ITAppBannerService appBannerService;

    @Resource
    ITAppStoreService appStoreService;

    @Resource
    ITAppPolicyNewsService appPolicyNewsService;

    @Resource
    ITAppEnterpriseQualificationRecordService appEnterpriseQualificationRecordService;

    @Resource
    ITAppEnterprisePolicySubsidiesRecordService appEnterprisePolicySubsidiesRecordService;

    @NotLogin
    @PostMapping(value = "/index",produces = "application/json; charset=UTF-8")
    @ApiOperation(value="APP首页加载")
    @ResponseBody
//    public String appUserRegister(@RequestBody LoginParam param, HttpServletRequest request) {
    public String appUserRegister(HttpServletRequest request) {
        //首页轮播图
        List<TAppBanner> appBannerList = appBannerService.selectList(TAppBanner.TYPE.type_pic,TAppBanner.SHOWTYPE.banner_index);
        AppStoreParam appStoreParam = new AppStoreParam();
        appStoreParam.setAmount(2);
        //门店
//        List<TAppStore> appStoreList = appStoreService.selectList(appStoreParam);
        List<AppStoreDTO> appStoreList = appStoreService.selectDtoList(appStoreParam);
        // 惠企政策  首页推送成免费的
        AppPolicyNewsParam appPolicyNewsParam = new AppPolicyNewsParam();
        appPolicyNewsParam.setChargeFlag(2);
        appPolicyNewsParam.setAmount(4);
        List<TAppPolicyNews> appPolicyNewsList = appPolicyNewsService.selectList(appPolicyNewsParam);
        return JsonReturn.success()
                .put("appBannerList",appBannerList)
                .put("appStoreList",appStoreList)
                .put("appPolicyNewsList",appPolicyNewsList)
                .toJsonStr();
    }


    /**
     * 企业政策补贴申请记录新增
     * @param param
     * @return
     */
    @NotLogin
    @PostMapping(value = "/addEnterprisePolicySubsidiesRecord",produces = "application/json; charset=UTF-8")
    @ApiOperation(value="企业政策补贴申请记录新增")
    @ResponseBody
    public String addEnterprisePolicySubsidiesRecord(@RequestBody EnterprisePolicySubsidiesRecordParam param) {
        return appEnterprisePolicySubsidiesRecordService.addEnterprisePolicySubsidiesRecord(param);
    }


    /**
     * 企业资质申请记录新增
     * @param param
     * @return
     */
    @NotLogin
    @PostMapping(value = "/addEnterpriseQualificationRecord",produces = "application/json; charset=UTF-8")
    @ApiOperation(value="企业资质申请记录新增")
    @ResponseBody
    public String addEnterpriseQualificationRecord(@RequestBody EnterprisePolicySubsidiesRecordParam param) {
        return appEnterpriseQualificationRecordService.addEnterpriseQualificationRecord(param);
    }






}
